home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Blitter / RandomPlot.s < prev    next >
Encoding:
Text File  |  1997-05-01  |  2.5 KB  |  104 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Random Plot
  3. ;-----------
  4. ;This is a graphical demonstration of the Random() functions.  The default
  5. ;is to use FastRandom, but you can change it to SlowRandom if you look
  6. ;below.
  7. ;
  8. ;LMB exits.
  9.  
  10.     INCDIR    "INCLUDES:"
  11.     INCLUDE    "games/games_lib.i"
  12.     INCLUDE    "games/games.i"
  13.  
  14. Random    =    _LVOFastRandom    ;_LVOFastRandom() or _LVOSlowRandom().
  15.  
  16. CALL    MACRO
  17.     jsr    _LVO\1(a6)
  18.     ENDM
  19.  
  20.     SECTION    "RandomPlot",CODE
  21.  
  22. ;===========================================================================;
  23. ;                             INITIALISE DEMO
  24. ;===========================================================================;
  25.  
  26.     STARTGMS
  27.  
  28. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  29.     move.l    GMSBase(pc),a6
  30.     CALL    AllocBlitter
  31.     tst.l    d0
  32.     bne.s    .Error_Blitter
  33.  
  34.     lea    ScreenTags(pc),a0
  35.     CALL    ShowScreen
  36.     tst.l    d0
  37.     beq.s    .Error_Screen
  38.  
  39.     bsr.s    Main
  40.  
  41. .ReturnToDOS
  42.     move.l    GMSBase(pc),a6
  43.     move.l    Screen(pc),a0
  44.     CALL    DeleteScreen
  45. .Error_Screen
  46.     CALL    FreeBlitter
  47. .Error_Blitter
  48.     MOVEM.L    (SP)+,A0-A6/D1-D7
  49.     moveq    #ERR_OK,d0
  50.     rts
  51.  
  52. ;===========================================================================;
  53. ;                                MAIN LOOP
  54. ;===========================================================================;
  55.  
  56. Main:    move.l    GMSBase(pc),a6
  57.     move.l    Screen(pc),a0
  58. .loop    moveq    #JPORT1,d0
  59.     CALL    ReadMouse
  60.     btst    #MB_LMB,d0
  61.     bne.s    .done
  62.  
  63.     move.l    GS_AmtColours(a0),d1    ;Get random colour.
  64.     subq.l    #1,d1
  65.     jsr    Random(a6)    ;>> = Get random number.
  66.     addq.l    #1,d0
  67.     move.l    d0,d3    ;d3 = Colour to use.
  68.  
  69.     move.w    GS_ScrWidth(a0),d1    ;Get random X.
  70.     jsr    Random(a6)    ;>> = Get random number.
  71.     move.w    d0,d4    ;d4 = Store X to use.
  72.  
  73.     move.w    GS_ScrHeight(a0),d1    ;Get random Y.
  74.     jsr    Random(a6)    ;>> = Get random number.
  75.     move.w    d0,d2    ;d2 = Y to use.
  76.     move.w    d4,d1    ;d1 = Get back X.
  77.  
  78.     moveq    #BUFFER1,d0
  79.     CALL    DrawUCPixel
  80.     CALL    AutoSwitch
  81.     bra.s    .loop
  82.  
  83. .done    rts
  84.  
  85. ;===========================================================================;
  86. ;                                  DATA
  87. ;===========================================================================;
  88.  
  89. ScreenTags:
  90.     dc.l    TAGS_GAMESCREEN
  91. Screen:    dc.l    0
  92.     dc.l    GSA_Palette,.palette
  93.     dc.l    GSA_AmtColours,32
  94.     dc.l    GSA_ScrWidth,640
  95.     dc.l    GSA_ScrHeight,512
  96.     dc.l    GSA_ScrMode,HIRES|LACED
  97.     dc.l    TAGEND
  98. .palette
  99.     dc.l    $000000,$109000,$F0C0B0,$F0A090,$D08080,$906050,$604040,$201010
  100.     dc.l    $400060,$404040,$F0F000,$403020,$C0C000,$109000,$500010,$808000
  101.     dc.l    $206010,$207010,$308020,$409020,$50A030,$50B040,$607070,$60C040
  102.     dc.l    $708080,$90A0A0,$B0C0C0,$800010,$900010,$A00020,$700010,$600010
  103.  
  104.